package com.quanquan.store.repository;

import com.quanquan.store.entity.History;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;

import java.util.List;

/**
 * @ClassName:HistoryReposity
 * @Description:TODO
 * @Author:xiongjunbao
 * @Date:2019/3/20 10:44
 * @Version 1.0
 */
public interface HistoryReposity extends JpaRepository<History, String> {

    @Query(value = "SELECT * FROM oo_history WHERE user_id = ?1 AND status_show = 0 AND status_remove = 0 order by update_time desc LIMIT ?2,?3", nativeQuery = true)
    List<History> queryByUserId(String userId, Integer count, Integer size);

    @Query(value = "SELECT * FROM oo_history WHERE status_show = 0 and status_remove = 0 and user_id = ?1 order by update_time desc", nativeQuery = true)
    List<History> queryByUserId(String userId);

    @Query(value = "SELECT * FROM oo_history WHERE status_show = 0 and status_remove = 0 and user_id = ?1 and store_id = ?2", nativeQuery = true)
    History queryByUserIdAndStoreId(String userId, String storeId);
}
